package fortunetelling.fortunetelling.utils;

import fortunetelling.fortunetelling.bean.Fortune;

import java.util.Random;

/**
 * @ClassName: FortuneConvertUtils
 * @Date: 2020/10/5 0005 17:58
 * @Description:
 */
public class FortuneConvertUtils {

    public static int GOOD = 1;
    public static int NORMAL = 0;
    public static int BAD = -1;

    public static Fortune translate(String name) {
        Fortune fortune = new Fortune();
        fortune.setName(name);
        switch (name) {
            case "大吉":
                fortune.setHint("暗示：大展鸿图，信用得固，名利双收，可获成功");
                fortune.setPoem("诗云：天地开泰万事成，身体康安亦富荣，否泰名誉兼享福，一生无忧乐绵长");
                break;
            case "大凶":
                fortune.setHint("暗示：根基不固，摇摇欲坠，一盛一衰，劳而无获");
                fortune.setPoem("诗云：混吨未定如萍动，乱离不安亦波浪，独立无力多遭难，凶变病弱福寿穷");
                break;
            case "凶":
                fortune.setHint("暗示：前途坎坷，苦难折磨，非有毅力，难望成功");
                fortune.setPoem("诗云：溯体凶变不具整，果落枝折病难多，山空鸟绝灾祸频，苦苦之中有孝人");
                break;
            case "半吉":
                fortune.setHint("暗示：万宝集门，天降幸运，立志奋发，得成大功");
                fortune.setPoem("诗云：安稳余庆福禄开，盛大幸福天赐来，内含衰兆应谨慎，注意品行福乐享");
                break;
            case "吉":
                fortune.setHint("暗示：独营生意，和气吉祥，排除万难，必获成功");
                fortune.setPoem("诗云：刚毅果断除万难，独立权威志气安，内外和好兼柔性，温和养德耀吉星");
                break;
            default:
                return null;
        }
        return fortune;
    }

    /**
     * @param name
     * @return
     */
    public static int probabilityCalculation(String name) {
        int randomInt = new Random().nextInt(100);
        int result;
        switch (name) {
            case "大吉":
                result = randomInt > 25 ? FortuneConvertUtils.GOOD : FortuneConvertUtils.NORMAL;
                break;
            case "大凶":
                result = randomInt > 25 ? FortuneConvertUtils.BAD : FortuneConvertUtils.NORMAL;
                break;
            case "凶":
                result = randomInt > 50 ? FortuneConvertUtils.BAD : FortuneConvertUtils.NORMAL;
                break;
            case "半吉":
                result = randomInt > 75 ? FortuneConvertUtils.GOOD : FortuneConvertUtils.NORMAL;
                break;
            case "吉":
                result = randomInt > 50 ? FortuneConvertUtils.GOOD : FortuneConvertUtils.NORMAL;
                break;
            default:
                return FortuneConvertUtils.NORMAL;
        }
        return result;
    }
}
